<?php
require_once("database.php");
class xl_tuyen_dung extends database
{
	function danh_sach($vi_tri, $so_luong)
	{
		$vi_tri = intval($vi_tri);
		$so_luong = intval($so_luong);
		$sql = "select * from tuyen_dung limit $vi_tri, $so_luong";
		$this->setQuery($sql);
		return $this->loadAllRow();
	}
	function so_luong()
	{
		$sql = "select count(*) from tuyen_dung";
		$this->setQuery($sql);
		return $this->loadResult();
	}
	function xem($ma)
	{
		$ma = intval($ma);

		$sql = "select * from tuyen_dung where ma = '$ma'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function kt_email($email)
	{
		$sql = "select * from tuyen_dung where email = '$email'";
		$this->setQuery($sql);
		return $this->loadRow();
	}
	function xoa($ma)
	{
		$ma = intval($ma);

		$sql = "delete from tuyen_dung where ma = '$ma'";
		$this->setQuery($sql);
		return $this->query();
	}
	function them($ho_ten, $ngay_sinh, $gioi_tinh, $dia_chi, $dien_thoai, $email, $vi_tri_ung_tuyen, $tu_gioi_thieu, $trang_thai)
	{
		$ho_ten = stripslashes($ho_ten);
		$ho_ten = addslashes($ho_ten);
		$dia_chi = stripslashes($dia_chi);
		$dia_chi = addslashes($dia_chi);
		$dien_thoai = stripslashes($dien_thoai);
		$dien_thoai = addslashes($dien_thoai);
		$email = stripslashes($email);
		$email = addslashes($email);
		$vi_tri_ung_tuyen = stripslashes($vi_tri_ung_tuyen);
		$vi_tri_ung_tuyen = addslashes($vi_tri_ung_tuyen);
		$tu_gioi_thieu = stripslashes($tu_gioi_thieu);
		$tu_gioi_thieu = addslashes($tu_gioi_thieu);

		$sql = "INSERT INTO tuyen_dung(ho_ten,ngay_sinh,gioi_tinh,dia_chi,dien_thoai,email,vi_tri_ung_tuyen,tu_gioi_thieu,trang_thai) VALUES ('$ho_ten','$ngay_sinh','$gioi_tinh','$dia_chi','$dien_thoai','$email','$vi_tri_ung_tuyen','$tu_gioi_thieu','$trang_thai')";
		$this->setQuery($sql);
		return $this->query();
	}
	function cap_nhat($ma, $ho_ten, $ngay_sinh, $gioi_tinh, $dia_chi, $dien_thoai, $email, $vi_tri_ung_tuyen, $tu_gioi_thieu, $trang_thai)
	{
		$ma = intval($ma);
		$ho_ten = stripslashes($ho_ten);
		$ho_ten = addslashes($ho_ten);
		$dia_chi = stripslashes($dia_chi);
		$dia_chi = addslashes($dia_chi);
		$dien_thoai = stripslashes($dien_thoai);
		$dien_thoai = addslashes($dien_thoai);
		$email = stripslashes($email);
		$email = addslashes($email);
		$vi_tri_ung_tuyen = stripslashes($vi_tri_ung_tuyen);
		$vi_tri_ung_tuyen = addslashes($vi_tri_ung_tuyen);
		$tu_gioi_thieu = stripslashes($tu_gioi_thieu);
		$tu_gioi_thieu = addslashes($tu_gioi_thieu);

		$sql ="UPDATE tuyen_dung SET ho_ten= '$ho_ten', ngay_sinh= '$ngay_sinh', gioi_tinh= '$gioi_tinh', dia_chi= '$dia_chi', dien_thoai= '$dien_thoai', email= '$email', vi_tri_ung_tuyen= '$vi_tri_ung_tuyen', tu_gioi_thieu= '$tu_gioi_thieu', trang_thai= '$trang_thai' WHERE ma = '$ma'";
		$this->setQuery($sql);
		return $this->query();
	}
	function tim_kiem ($tu_khoa)
	{
		$sql = "select * from tuyen_dung where	$ho_ten like %tu_khoa% or 	$dia_chi like %tu_khoa% or 	$dien_thoai like %tu_khoa% or 	$email like %tu_khoa% or 	$vi_tri_ung_tuyen like %tu_khoa% or 	$tu_gioi_thieu like %tu_khoa%"; 
		$this->setQuery($sql);
		return $this->loadAllRow();	
	}
 }
?>